<template>
  <div>
    <van-nav-bar
        :title="'已学(' + leaned + ')/(' + all + ')全部'"
        left-text="返回"
        right-text="保存"
        left-arrow
        @click-left="onClickLeft"
        @click-right="onClickRight"
    />
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
      <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
      >
        <div class="item-row" v-for="(item, index) in list" :key="item.word">
          <span>{{ index + 1 }}</span>
          <div class="item-col-large">
            <span>{{ item.word }} [asdasd]</span>
            <div class="item-col-large" v-html="item.explains">
            </div>
            <span>+</span>
          </div>
          <div class="item-col-small">
            <van-checkbox v-model="item.unknown"></van-checkbox>
            <van-icon name="star-o"></van-icon>
          </div>
        </div>

        <!--        <van-cell v-for="item in list" :key="item.word" :title="item.word" :value="item.leaned + '/' + item.all"/>-->
        <!--        <div v-for="item in list" :key="item.word" class="item-row">-->
        <!--          <van-radio name="1"/>-->
        <!--          <div class="item-col">-->
        <!--            <span>张=13000000000</span>-->
        <!--            <span>浙江省杭州市西湖区文三路 138 号东方通信大厦7楼501室</span>-->
        <!--          </div>-->
        <!--          <van-icon name="edit"></van-icon>-->
        <!--        </div>-->
      </van-list>
    </van-pull-refresh>
  </div>
</template>

<script>
export default {
  data() {
    return {
      leaned: 2000,
      all: 6000,
      list: [],
      loading: false,
      finished: false,
      refreshing: false,
    };
  },
  methods: {
    onLoad() {
      setTimeout(() => {
        if (this.refreshing) {
          this.list = [];
          this.refreshing = false;
        }

        for (let i = 0; i < 10; i++) {
          this.list.push({word: 'xxx' + (this.list.length + 1), leaned: 10, all: 100, unknown: false, explains: 'n.asdasd\nv.asdasda\na.asdadasd'});
        }
        this.loading = false;

        if (this.list.length >= 40) {
          this.finished = true;
        }
      }, 1000);
    },
    onRefresh() {
      // 清空列表数据
      this.finished = false;

      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      this.loading = true;
      this.onLoad();
    },
    onClickLeft() {
      this.$router.go(-1);
    },
    onClickRight() {
      this.$router.go(-1);
    },
  }
}
</script>

<style>

</style>
